<?php
class main {
	public function __construct() {
		echo ("hello");
	}
	public static function loader() {
		header ( "Content-Type: text/html; charset=utf-8" );
		error_reporting ( 7 );
		ini_set ( "memory_limit", "128M" );
		date_default_timezone_set ( 'Asia/Shanghai' );
		set_include_path ( '.' . PATH_SEPARATOR . '../library' . PATH_SEPARATOR . '../library/incubator' . PATH_SEPARATOR . '../application/default/models' . PATH_SEPARATOR . get_include_path () );
		include "Zend/Loader.php";
		Zend_Loader::registerAutoload ();
		$config = new Zend_Config_Xml ( '../config/Config.xml', 'staging' );
		
		$db = Zend_Db::factory ( $config->database->adapter, $config->database->config->toArray () );
		$db->query ( "set names {$config->database->charset};" );
		Zend_Db_Table::setDefaultAdapter ( $db );
		Zend_Registry::set ( 'db', $db );
		//
		

		Zend_Session::setSaveHandler ( new Zend_Session_SaveHandler_DbTable ( $config->session->toArray () ) );
		Zend_Session::start ();
		
		include ('../library/My/xml.php'); //
		$config = array ('auth' => 'login', 'username' => '2012728', 'password' => '315162' );
		$tr = new Zend_Mail_Transport_Smtp ( 'smtp.qq.com', $config );
		Zend_Mail::setDefaultTransport ( $tr );
		$frontController = Zend_Controller_Front::getInstance ();
		$frontController->setControllerDirectory ( array ('default' => '../application/default/controllers', 'admin' => '../application/admin/controllers' ) );
		$router = $frontController->getRouter ();
		$router->addRoute ( 'goods_view', new Zend_Controller_Router_Route_Regex ( 'g(\d+).html', array ('controller' => 'goods', 'action' => 'view' ), array (1 => id ) ) );
		$router->addRoute ( 'articles_view', new Zend_Controller_Router_Route_Regex ( 'a(\d+).html', array ('controller' => 'articles', 'action' => 'view' ), array (1 => id ) ) );
		$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper ( 'viewRenderer' );
		$viewRenderer->setViewSuffix ( 'php' );
		try {
			$frontController->dispatch ( $request, $response );
		} catch ( Exception $dispatch_exception ) {
			$request = new Zend_Controller_Request_Http ( );
			$request->setRequestUri ( '/error/error' );
			
			$response = new Zend_Controller_Response_Http ( );
			
			$frontController->dispatch ( $request, $response );
		}
	}
}
main::loader ();